V2EX  ›  英汉词典
Enqueued related words: ES Modules

Tree Shaking

释义 Definition

Tree shaking 指在打包(bundling)过程中,自动“摇掉”未被使用的代码(尤其是未被引用的导出内容),从而减小最终产物体积、提升加载与执行效率。该术语最常见于 JavaScript/TypeScript 以及现代前端构建工具生态中。

发音 Pronunciation (IPA)

/triː ˈʃeɪkɪŋ/

例句 Examples

Tree shaking removes unused exports to reduce bundle size.
Tree shaking 会移除未使用的导出内容,从而减小打包体积。

Because the library is written with ES modules and has no side effects, the bundler can apply tree shaking aggressively and ship less code to users.
由于这个库使用 ES 模块编写且没有副作用,打包器可以更积极地进行 tree shaking,从而向用户交付更少的代码。

词源 Etymology

字面意思是“摇树”。比喻像摇晃一棵树把枯叶、无用枝叶抖落一样:在构建产物中“抖掉”不会被运行到的代码。该说法在现代前端工具链兴起后广泛流行,常与 ES module 的静态分析能力一起出现。

相关词 Related Words

文学/著作中的用例 Literary / Notable Works

  • Rollup.js Documentation(Rollup 文档中将 tree shaking 作为核心特性频繁提及)
  • webpack Documentation(webpack 文档与指南中常用于解释 production 优化与 sideEffects 配置)
  • SurviveJS — Webpack(前端构建书籍中系统讨论 tree shaking、代码分割与优化策略)
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   646 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 20:51 · PVG 04:51 · LAX 12:51 · JFK 15:51
♥ Do have faith in what you're doing.